<template>
  <div class="app-container">
    <div class="mt20 mb20 ml10 font-size-20">{{ allName }} 高龄库存</div>
    <el-table
      v-loading="loading"
      :data="highAgeLeftGoodsList"
    >
      <af-table-column prop="sptm" label="条码" fixed="left"></af-table-column>
      <af-table-column prop="sptmc" label="仓库条码"></af-table-column>
      <af-table-column prop="spgh" label="柜号" min-width="150"></af-table-column>
      <af-table-column prop="spbh" label="批号"></af-table-column>
      <af-table-column prop="spckmc" label="仓库"></af-table-column>
      <af-table-column prop="ckcw" label="仓位"></af-table-column>
      <af-table-column prop="spjs" label="件数"></af-table-column>
      <af-table-column prop="spsl" label="重量(吨)"></af-table-column>
      <af-table-column prop="spcd" label="品牌"></af-table-column>
      <af-table-column prop="days" label="结存天数"></af-table-column>
      <af-table-column prop="ssrqid" label="入仓日期"></af-table-column>
    </el-table>
     <pagination
        v-show="total>0"
        :total="total"
        :page.sync="pageNum"
        :limit.sync="pageSize"
        @pagination="getList"
      />
  </div>
</template>

<script>
import { getListHighAgeLeftGoods } from "@/api/storage/dataAnalysis/highAgeGoods";

export default {
  name: "HighAgeLeftGoods",
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      //对齐
      labelPosition: "right",
      //加载列表
      loading: true ,
      //标题
      allName: "",
      // 查询参数
      queryParams: {
        gaoling: "",
        khid: "",
      },
      // 高龄货物剩余货物
      highAgeLeftGoodsList: [],
      //页数
      pageSize: 10,
      //页码
      pageNum:1,
      // 总条数
      total: 0,
    };
  },
  beforeRouteEnter(to, from, next) {
    const query = to.query
    next(vm => {   
      if(Object.keys(query).length > 0) {
        vm.queryParams.khid = query.khid
        vm.queryParams.gaoling = query.gaoling
        vm.allName = query.allName
        vm.getList()
      }
    })
  },
  methods: {
    /** 查询高龄货物剩余货物 */
    getList() {
      this.loading  = true
      getListHighAgeLeftGoods(this.queryParams, {pageNum:this.pageNum, pageSize:this.pageSize}).then(response => {
        this.highAgeLeftGoodsList = response.rows;
        this.total = response.total;
        this.loading = false
      });
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.reset()
      this.getList()
    },
    reset() {
      Object.assign(this.$data, this.$options.data())
    },
  }
};
</script>
